<!--文章列表页 ArticleListView.vue-->
<template>
  <div style="height: 6vh;background-color:#fff;padding:10px 20px;">
    <span style="line-height:60px;font-size:20px;">信息管理</span>
  </div>
  <el-card style="margin:20px;height: 140px;">
    <el-form :inline="true">
      <el-form-item label="文章标题">
        <el-input placeholder="请输入" style="width:300px;" v-model="searchForm.name" ></el-input>
      </el-form-item>
      <el-form-item label="文章分类" style="width:300px;">
        <el-select placeholder="请选择" v-model="searchForm.article" @change="load">
          <el-option label="全部" value="0"/>
          <el-option label="启用" value="1"/>
          <el-option label="禁用" value="2"/>
        </el-select>
      </el-form-item>
      <el-form-item label="发布状态" style="width:300px;">
        <el-select placeholder="请选择" v-model="searchForm.status" @change="load">
          <el-option label="全部" value="0"/>
          <el-option label="启用" value="1"/>
          <el-option label="禁用" value="2"/>
        </el-select>
      </el-form-item>
      <el-form-item label="关联活动" style="width:300px;">
        <el-select placeholder="请选择" v-model="searchForm.activity" @change="load">
          <el-option label="全部" value="0"/>
          <el-option label="启用" value="1"/>
          <el-option label="禁用" value="2"/>
        </el-select>
      </el-form-item>
      <el-form-item label="更新日期" style="width:290px;">
        <el-date-picker
            type="datetimerange"
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            value-format="YYYY-MM-DD HH:mm:ss"
            format="YYYY-MM-DD HH:mm:ss"
            v-model="times"
        ></el-date-picker>
      </el-form-item>
      <el-form-item>
        <el-button @click="resetSearch">重置</el-button>
        <el-button type="primary" @click="load">查询</el-button>
      </el-form-item>
    </el-form>
  </el-card>
  <!-- 店铺列表表格数据 -->
  <el-card style="margin:20px;">
    <h3>店铺列表</h3>
    <el-table stripe :data="tableData">
      <el-table-column label="编号" prop="id" type="index" align="center" width="100"></el-table-column>
      <el-table-column label="文章标题" prop="storeName" align="center"></el-table-column>
      <el-table-column label="文章分类" prop="storeLocation" align="center"></el-table-column>
      <el-table-column label="活动标题" prop="storePhone" align="center"></el-table-column>
      <el-table-column label="创建时间" prop="createTime" align="center"></el-table-column>
      <el-table-column label="更新时间" prop="updateTime" align="center"></el-table-column>
      <el-table-column label="启用状态" align="center">
        <template #default="scope">
          <el-switch inactive-value="0" active-value="1" v-model="scope.row.status"
                     @change="changeStatus(scope.row.id,scope.row.status)"></el-switch>
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center">
          <el-button type="primary" link @click="deleteArticle">下线</el-button>
      </el-table-column>
    </el-table>
  </el-card>
</template>
<script setup>
import {onMounted, ref} from "vue";
import qs from "qs";

const times =ref([]);
const searchForm = ref({name: '', article:'',activity:'',status: ''})
const tableData = ref([]);
const load = ()=>{
  let data = qs.stringify(searchForm.value);
  // axios.get(BASE_URL+'/v1/geofence/select?'+data).then((response)=>{
  //   if(response.data.code == 2000){
  //     geoTableData.value = response.data.data;
  //   }else{
  //     ElMessage.error(response.data.msg);
  //   }
  // })
}
onMounted(()=>{
  load();
})
//定义重置搜索的方法
const resetSearch = ()=>{
  searchForm.value = {name: '', status: ''};
  load();
}
const changeStatus = (id,status)=>{
  let data = qs.stringify({id:id,status:status});
  // axios.post(BASE_URL+'/v1/geofence/save',data).then((response)=>{
  //   if(response.data.code==2000){
  //     ElMessage.success('状态修改成功!');
  //   }else{
  //     ElMessage.error(response.data.msg);
  //   }
  // })
}
const deleteArticle = ()=>{
  if(confirm('此操作将下线该文章, 是否继续?')){

  }
}

</script>



<style scoped>
</style>